home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
VISUALBA
/
PBCWIN.ZIP
/
PBCWIN.DOC
< prev
next >
Wrap
Text File
|
1993-01-22
|
34KB
|
1,130 lines
The PBClone Windows Library
=-----------------------------=
Version 1.0
PBCwin Copyright (c) 1993 Thomas G. Hanlin III
This is PBCwin, a general-purpose library of 79 routines for
use with Visual Basic for Windows. The PBCwin collection is
copyrighted and may be distributed only under the following
conditions:
All PBCwin files must be distributed together as a unit.
No files may be altered, added, or deleted from this unit.
You use this library at your own risk. It has been tested by
me on my own computer, but I will not assume any responsibility
for any problems which PBCwin may cause you. If you do run
into a problem, please let me know about it, and I will do my
best to verify and repair it.
It is expected that if you find PBCwin useful, you will
register your copy. You may not use PBCwin routines in
programs intended for sale unless you have registered.
Registration gives you the right to distribute the PBCWIN.DLL
library with your programs. It also gets you the latest
version of PBCwin, complete with full source code (written in
Microsoft C 7.0).
The PBCwin library can be used with any Windows language that
can access DLLs. It is currently documented only for VB/Win,
however. I expect to extend the documentation to cover other
languages in future versions. PBCwin will be expanding greatly
over the course of the next year or so, as I get a better grip
on the idiosyncracies of Windows programming.
If you're familiar with DOS libraries, you'll have no trouble
at all with Windows libraries. There's one important thing to
keep in mind, however. DOS libraries are almost always linked
into your .EXE program and become an integral part of it.
Windows libraries are separate from your program and must be
available to Windows when your program is run. This allows
multiple programs to share the same library code for greater
memory efficiency. It also means you will need to distribute
the PBCWIN.DLL file with your programs that use it (legal only
for registered PBCwin owners), or simply tell people where they
can get a copy of PBCwin to use with your program.
In order to use any of the PBCwin routines in a VB/Win program,
you must place the appropriate declarations in the globals
section of the program. These declarations can be taken
individually or en masse from the PBCWIN.BI text file.
The PBCwinVer function will let you make sure that the version
of PBCWIN.DLL that is being used is, in fact, sufficiently
current as to support the routines your program requires.
Name : BinI (Binary Integer)
This function converts a binary value, passed to it as a
string, to an integer. It stops the conversion on reaching the
end of the string or at the first character that is not a valid
binary digit ("0" or "1").
See also BinL, which returns a long integer value.
Result% = BinI(St$)
St$ binary number, in string form
-------
Result% integer equivalent of binary number
Name : BinL (Binary Long)
This function converts a binary value, passed to it as a
string, to a long integer. It stops the conversion on reaching
the end of the string or at the first character that is not a
valid binary digit ("0" or "1").
See also BinI, which returns an integer value.
Result& = BinL(St$)
St$ binary number, in string form
-------
Result& long integer equivalent of binary number
Name : Bytes2Int (Bytes to Integer)
This function combines two bytes, contained in separate
integers, into a single integer value.
See also HiByte and LoByte, which may be used to reverse the
process, splitting an integer into two bytes.
Result% = Bytes2Int(Lo%, Hi%)
Lo% low, or least significant, byte
Hi% high, or most significant, byte
-------
Result% result of combining bytes into an integer
Name : Checksum (Checksum)
This function calculates an 8-bit checksum for a string. The
result is compatible with Xmodem and Ymodem file transfer
protocols, and can be used as a fast and simple check of data
validity. For more rigorous testing, see CRC16.
Result% = Checksum(St$, Bytes%)
St$ string for which to calculate checksum
Bytes% number of characters for which to calculate checksum
-------
Result% checksum of specified part of string
Name : ComPorts (Comm Ports)
This function returns the number of communications (serial)
ports installed.
Result% = ComPorts()
-------
Result% comm ports (0-3)
Name : CRC16 (CRC, 16-bit)
This function calculates a 16-bit "cyclical redundancy check"
checksum, or CRC, for a string. The result is compatible with
Xmodem and Ymodem file transfer protocols, and can be used as a
check of data validity.
Note that the Xmodem and Ymodem file transfer protocols use a
different byte ordering method than typical of Intel machines.
If you intend to use this function in writing file transfer
protocols, you will need to reverse the byte order to MSB
first, LSB second. This can be accomplished with either
LRotateI or RRotateI with a shift count of 8 (eight), or by
splitting the integer into bytes with LoByte and HiByte, and
swapping the results.
Result% = CRC16(St$, Bytes%)
St$ string for which to calculate CRC
Bytes% number of characters for which to calculate CRC
-------
Result% CRC of specified part of string
Name : DateSq (Date Squeeze)
This function compresses a date into a single integer. This
provides a very efficient storage format for dates ranging from
January 1, 1900 to December 31, 2028.
Uncompression is done with DayUnsq, MonthUnsq, and YearUnsq.
See also TimeSq, which allows you to compress a time value
similarly.
Note that compressed dates are not in a format that may be
readily used for comparison or date math purposes. If you need
such capabilities, convert the date to a BASIC time/date serial
number first-- see your BASIC manual for details.
If you pass a year of 0-99, it will be translated to 1900-1999
before the compression is done. Depending on your application,
you may wish to assume 0-28 is the same as 2000-2028 instead.
If so, make sure you do an explicit conversion before this
function is called.
Result% = DateSq(MonthNr%, DayNr%, YearNr%)
MonthNr% month number (1-12)
DayNr% day number (1-31)
YearNr% year number (1900-2028)
-------
Result% compressed date
Name : DayUnsq (Day Unsqueeze)
This function returns the day from a compressed date. It works
in conjunction with the DateSq date compression function.
DayNr% = DayUnsq(Number%)
Number% compressed date
-------
DayNr% day number
Name : Floppies (Floppies)
This function returns the number of floppy disk drives
installed, up to two. Although it is possible to have up to
four floppy drives, the PC was designed to expect a maximum of
two, and this routine can't tell if there are more than that.
Result% = Floppies()
-------
Result% floppy drives (0-2)
Name : GetComAddr (Get Comm Address)
This function returns the I/O base port address for a specified
communications (serial) port. If there is no such serial port,
or if the port is in use, a zero will be returned.
Address% = GetComAddr(PortNr%)
PortNr% communications port number (0-3)
-------
Address% I/O base port address for comm port
Name : GetPrtAddr (Get Prt Address)
This function returns the I/O base port address for a specified
printer (parallel) port. If there is no such parallel port, a
zero will be returned.
Address% = GetPrtAddr(PortNr%)
PortNr% printer port number (0-3)
-------
Address% I/O base port address for printer port
Name : GetTick (Get clock Tick)
This function returns the current system time count. The count
is the amount of time after midnight, in (approximately) 1/18